package com.tl.architecture.base.activity

import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

/**
 * databinding activity
 */
abstract class BaseVDBActivity<VDB : ViewDataBinding> : BaseActivity() {
    var dataBinding: VDB? = null

    override fun initContentView() {
        dataBinding = DataBindingUtil.setContentView(this, getLayoutId())
        dataBinding?.lifecycleOwner = this//将设置数据的生命周期与activity绑定
    }

    abstract fun getLayoutId(): Int

    override fun onDestroy() {
        super.onDestroy()
        dataBinding = null//防止内存泄露
    }
}